package org.jeecg.modules.vehicle.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.vehicle.entity.WlhyVehicle;
import org.jeecg.modules.vehicle.req.WlhyVehicleBody;
import org.jeecg.modules.vehicle.service.IWlhyVehicleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;

/**
* @Description: 车辆表
* @Author: jeecg-boot
* @Date:   2024-04-15
* @Version: V1.0
*/
@Api(tags="车辆Api")
@RestController
@RequestMapping("/user-api/vehicle/wlhyVehicle")
@Slf4j
public class WlhyVehicleApi extends JeecgController<WlhyVehicle, IWlhyVehicleService> {
   @Autowired
   private IWlhyVehicleService wlhyVehicleService;



   /**
    *   编辑或新增
    *
    * @param wlhyVehicleBody
    * @return
    */
   @AutoLog(value = "车辆表-编辑或新增")
   @ApiOperation(value="车辆表-编辑或新增", notes="车辆表-编辑或新增")
   @PostMapping(value = "/add")
   public Result<String> add(@RequestBody @Validated WlhyVehicleBody wlhyVehicleBody) {
       wlhyVehicleService.add(wlhyVehicleBody);
       return Result.OK("操作成功！请等待人工审核");
   }




   /**
    * 获取车辆信息
    *
    * @return
    */
   //@AutoLog(value = "车辆表-获取车辆信息")
   @ApiOperation(value="车辆表-获取车辆信息", notes="车辆表-获取车辆信息")
   @GetMapping(value = "/myVehicle")
   public Result<WlhyVehicle> myVehicle() {
       LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
       WlhyVehicle wlhyVehicle = wlhyVehicleService.getByUserId(loginUser.getId());
       return Result.OK(wlhyVehicle);
   }


}
